feat(scoring): expose merged scorer output#3
Draft
ovitrif wants to merge 2 commits into
Draft
Conversation
c7801e0 to
0a47329
Compare
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2.
Context
This PR adds the small write/merge/filter API surface needed by
scorer-kitafter the diagnostics API from #2.The immediate use case is offline score-file tooling: read serialized LDK scorer files, inspect their contents, compare them, selectively merge entries into a new
ChannelLiquiditiesfile, and write that file back out for downstream tooling.The goal is to let external tooling build an auditable scorer file instead of treating one scorer source as globally authoritative.
What Changed
ChannelLiquidities::merge(...)as a simple default merge helper. It decays both inputs to a shared timestamp, preserves unique entries, and combines duplicate short-channel-id entries using LDK existing per-channel merge semantics.ChannelLiquidities::merge_with(...)for policy-driven duplicate handling. The caller gets diagnostic views of both duplicate entries and can chooseKeepExisting,ReplaceWithOther, orCombineper channel.ChannelLiquidities::remove(scid)so offline tooling can filter decoded scorer files before merging or re-serializing them.ChannelLiquidityMergeActionto make duplicate-resolution choices explicit.CombinedScorer::scores()so callers that use the existingCombinedScorer::merge(...)path can explicitly serialize the in-memory combined state. This intentionally does not changeCombinedScorerwrite behavior, which still persists local-only scores.Why Policy-Driven Merge
Blindly averaging every duplicate scorer entry is not obviously correct when combining independently generated scorer files. One source may be better for most overlapping channels, while another may be better for a smaller explicitly selected set.
This PR keeps the low-level LDK operation available, but lets external tooling own the actual merge policy. That policy can be deterministic and auditable: prefer richer history, prefer newer datapoints, preserve a baseline source by default, or explicitly overlay selected short-channel-ids.
Test Plan
cargo test -p lightning --lib channel_liquidities_cargo test -p lightning --lib routing::scoring::tests::